//
//  HZRewardDetailView.m
//  Stock_Stategy
//
//  Created by zeroing on 17/6/5.
//  Copyright © 2017年 MayerF. All rights reserved.
//

#import "HZRewardDetailView.h"
#import "HZRewardDetailHeaderView.h"
#import "HZRewardDetailDownView.h"

@interface HZRewardDetailView()
@property (nonatomic, strong)UIScrollView             *pScrollView;
@property (nonatomic, strong)UIView                   *pContentSizeView;
@property (nonatomic, strong)HZRewardDetailHeaderView *pHeaderView;
@property (nonatomic, strong)HZRewardDetailDownView   *pDownView;
@end

@implementation HZRewardDetailView

#pragma mark -
#pragma mark 生命周期
- (instancetype)init{
    self = [super init];
    if (self) {
        [self commonInit];
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}
#pragma mark -
#pragma mark private
- (void)commonInit{
    _pScrollView = [UIScrollView new];
    _pContentSizeView = [UIView new];
    _pHeaderView = [HZRewardDetailHeaderView new];
    _pDownView = [HZRewardDetailDownView new];
    
    _pHeaderView.layer.borderWidth = 0.5;
    _pHeaderView.layer.borderColor = kMYHexToRGB(0xc8c7cc, 1).CGColor;
    _pHeaderView.layer.masksToBounds = YES;
    
    [self addSubview:_pScrollView];
    [_pScrollView addSubview:_pContentSizeView];
    [_pContentSizeView addSubview:_pHeaderView];
    [_pContentSizeView addSubview:_pDownView];
    [self p_initConstraints];
}

- (void)p_initConstraints
{
    [_pScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self);
    }];
    [_pContentSizeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(_pScrollView);
        make.width.mas_equalTo(self);
        make.bottom.mas_equalTo(_pDownView);
    }];
    [_pHeaderView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(_pContentSizeView);
        make.left.right.mas_equalTo(self);
    }];
    [_pDownView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_pHeaderView.mas_bottom);
        make.left.right.mas_equalTo(self);
    }];
}
#pragma mark -
#pragma mark public
- (void)updateNewData:(HZRewardListModel *)data
{
    [_pHeaderView updateNewData:data];
    [_pDownView updateNewData:data];
}


@end
